package com.xujc.controller;

import com.opensymphony.xwork2.ActionSupport;
import com.xujc.dao.IDiscusDAO;
import com.xujc.entity.DiscuseEntity;
import org.apache.struts2.interceptor.ParameterAware;

import java.util.Map;

/**
 * Created by xujc on 6/21/15.
 */
public class DiscusAction extends ActionSupport implements ParameterAware{

    private Map<String, String[]> mMap;
    private IDiscusDAO mDiscusDAO;
    private DiscuseEntity mDiscus;

    @Override
    public void setParameters(Map<String, String[]> map) {
        mMap = map;
    }


    public void setDiscusDAO(IDiscusDAO discusDAO) {
        mDiscusDAO = discusDAO;
    }

    @Override
    public String execute() throws Exception {
        mDiscus = mDiscusDAO.getDiscus(Integer.parseInt(mMap.get("did")[0]));
        return SUCCESS;
    }

    public DiscuseEntity getDiscus() {
        return mDiscus;
    }
}
